package image;

import gui.Mode;

public class Shape 
{
	public static void resize(javafx.scene.shape.Shape s, Mode m, double width, double height)
	{
		switch (m)
		{
		case Rectangle:
			((javafx.scene.shape.Rectangle)s).setWidth(width);
			((javafx.scene.shape.Rectangle)s).setHeight(height);
			break;
		case Ellipse:
			((javafx.scene.shape.Ellipse)s).setRadiusX(width / 2);
			((javafx.scene.shape.Ellipse)s).setRadiusY(height / 2);
			break;
		case Line:
			javafx.scene.shape.Line line = (javafx.scene.shape.Line)s;
			line.endXProperty().bind(line.startXProperty().add(width));
			line.endYProperty().bind(line.startYProperty().add(height));	// Make sure the end is always start + width / height
			break;
		default: 
			((javafx.scene.shape.Rectangle)s).setWidth(width);
			((javafx.scene.shape.Rectangle)s).setHeight(height);
			break;
		}
	}
	
	public static void translate(javafx.scene.shape.Shape s, Mode m, double x, double y)
	{
		switch (m)
		{
		case Ellipse:
			javafx.scene.shape.Ellipse e = (javafx.scene.shape.Ellipse)s;
			e.setTranslateX(x + e.getRadiusX());
			e.setTranslateY(y + e.getRadiusY());
			break;
		case Line:
			javafx.scene.shape.Line line = (javafx.scene.shape.Line)s;
			line.setStartX(x);
			line.setStartY(y);
			break;
		default:
			s.setTranslateX(x);
			s.setTranslateY(y);
			break;
		}
	}
}
